#ifndef RENDER_OBJECT_H_
#define RENDER_OBJECT_H_

#include <vector>
#include <string>
#include <GL/glew.h>

#include "shaders.h"
#include "materials.h"
#include "../mathematics.h"
#include "mesh.h"
using namespace std;

/* NAME: RenderObject
 *
 * DESC: Used in rendering. It contains vector of buffers for use in VBO.
 * "BufferTypes" contains info about types (in-shader location) of buffers.
 */
class RenderObject
{
	protected:
        CMaterial *pMaterial;
        ShaderProgram *pShader;
        Matrix4x4 *pMatWorld;

		vector<GLuint> Buffers;
		vector<int> BufferTypes;
		vector<int> BufferComponentsNo;
		vector<GLenum> BufferDataType;

		int nVerticesNo;
	public:
        RenderObject();

		int NewBuffer(int AttribLocation, int nComponentsNo, GLenum DataType); //returns index of new buffer

		void BufferData(int nBufferIndex, GLsizeiptr Size, const GLvoid *Data, GLenum Usage, int nVerticesNo);

		void BindBuffers();
        void BindSingleBuffer(int nWhich);

        void EnableAttributes();
        void DisableAttributes();

        void Render(GLint nPrimitiveType = GL_TRIANGLES);

        void SetWorldMatrix(Matrix4x4 *pNewMatrix);
        void SetMaterial(CMaterial *pNewMaterial);
        void SetShader(ShaderProgram *pNewShader);
        void SetMesh(Mesh *pMesh);

        void UseMaterial();

        ShaderProgram* GetShaderPointer(){return pShader;}
        CMaterial* GetMaterialPointer(){return pMaterial;}
        Matrix4x4* GetWorldMatrixPointer(){return pMatWorld;}
};

#endif
